﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CycleTimeReport.CApCTRExcelExporter
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using Microsoft.CSharp.RuntimeBinder;
using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq.Expressions;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Olp;
using Tecnomatix.Engineering.Olp.PrivateImplementationDetails;
using Tecnomatix.Engineering.PrivateImplementationDetails;


namespace DnProcessSimulateCommands.CycleTimeReport;

public class CApCTRExcelExporter
{
  private const int N_TOTALS_TITLE = 3;
  private const int FIRST_COL = 0;
  private const int MAX_COL = 10;
  private const int FIRST_COL_WIDTH = 20;
  private const int SECOND_COL_WIDTH = 20;
  private const int THIRD_COL_WIDTH = 20;
  private const int FOURTH_COL_WIDTH = 22;
  private const int FIFTH_COL_WIDTH = 20;
  private const int SIXTH_COL_WIDTH = 40;
  private const int SEVENTH_COL_WIDTH = 40;
  private const int EIGHTH_COL_WIDTH = 40;
  private const int NINTH_COL_WIDTH = 40;
  private const int TENTH_COL_WIDTH = 40;
  private const int ELEVENTH_COL_WIDTH = 40;
  private const int SECOND_COL_WIDTH_SETTINGS = 10;
  private const int FONT_SIZE = 13;
  internal Application m_XL;
  internal Workbook m_WB;
  private _Worksheet m_Worksheet;
  private CultureInfo m_oldCI;
  private ResourceManager m_rm;
  private int m_rowsInHeader;
  private int m_timerTableTitleRow;
  private int m_summaryRow;
  private int m_totalCount;
  private int m_timerCount;
  private int m_weldCount;
  private int m_lastColumn;
  private double m_cycleStartTime;
  private bool m_showControllerComment;
  private bool m_showTimerPriorityColumns = true;
  private TxOlpControllerUtilities m_controllerUtilities = new TxOlpControllerUtilities();
  private int m_indexStartTime;
  private int m_indexActiveDuration = 1;
  private int m_indexEndTime = 2;
  private int m_indexInactiveDuration = 3;
  private int m_indexPriority = 4;
  private int m_indexTimerName = 5;
  private int m_indexParameters = 6;
  private int m_indexTimerDescription = 7;
  private int m_indexOLPCommands = 8;
  private int m_indexFanucRJComments = 9;
  private int m_indexRobotName = 10;
  private TxRobot masterRobot;

  internal CApCTRExcelExporter()
  {
  }

  internal void InitExcel(bool ignoreTimerPriority = false)
  {
    this.m_oldCI = Thread.CurrentThread.CurrentCulture;
    this.m_XL = (Application) Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
    this.m_showTimerPriorityColumns = !ignoreTimerPriority;
    this.m_rm = CApCTRUtilities.GetResourceManager();
  }

  internal void CreateExcelSheetForOneRobotOrCompound(
    string key,
    List<CApCTRTimer> timers,
    int cycleNumber,
    string programNumber)
  {
    if (timers.Count <= 0)
      return;
    this.m_timerCount = timers.Count;
    this.m_cycleStartTime = timers[0].StartTime;
    this.m_showControllerComment = this.ShouldShowComment(timers[0].Robot);
    this.m_weldCount = 0;
    this.m_lastColumn = 10;
    if (!this.m_showControllerComment)
      --this.m_lastColumn;
    if (!this.m_showTimerPriorityColumns)
      this.m_lastColumn -= 2;
    bool isCompoundEquipment = this.IsRobotPartOfCompoundEquipmentWithMoreThanOneRobot(timers[0].Robot, ref programNumber);
    if (!isCompoundEquipment)
      --this.m_lastColumn;
    this.InitiliazeColumnsIndex();
    this.CreateNewWorksheet();
    string name = ((TxBaseGeometryCreationObject) timers[0].Robot).Name;
    if (isCompoundEquipment)
    {
      name = ((ITxObject) ((TxBaseGeometryCreationObject) timers[0].Robot).Collection).Name;
      this.masterRobot = this.GetMasterRobot(((TxBaseGeometryCreationObject) timers[0].Robot).Collection);
    }
    else
      this.masterRobot = (TxRobot) null;
    this.SetNameOfSheet(name);
    this.FillExcelReportHeader(timers, cycleNumber, programNumber, isCompoundEquipment);
    this.FillExcelTotals(timers);
    this.FillExcelTimerTableTitle(isCompoundEquipment);
    this.FillExcelTimerTable(timers, isCompoundEquipment);
    this.FillExcelEndSummary(timers);
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__18.\u003C\u003Ep__0 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__18.\u003C\u003Ep__0 = CallSite<Func<CallSite, object, int, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.SetMember(CSharpBinderFlags.None, "Value2", typeof (CApCTRExcelExporter), (IEnumerable<CSharpArgumentInfo>) new CSharpArgumentInfo[2]
      {
        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, (string) null),
        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, (string) null)
      }));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    object obj = CApCTRExcelExporter.\u003C\u003Eo__18.\u003C\u003Ep__0.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__18.\u003C\u003Ep__0, this.m_Worksheet.Cells[(object) (this.m_rowsInHeader + 3 + this.m_totalCount), (object) 2], this.m_weldCount);
    this.FormatWorksheet(timers.Count);
  }

  internal void SetNameOfSheet(string suggested_name)
  {
    string name_after;
    this.ConvertNameToValidExcelTabName(suggested_name, out name_after);
    if (this.NoSheetWithThisName(name_after))
    {
      this.m_Worksheet.Name = name_after;
    }
    else
    {
      if (name_after.Length + 1 + this.m_Worksheet.Name.Length + 1 >= 31 /*0x1F*/)
        return;
      this.m_Worksheet.Name = $"{name_after}({this.m_Worksheet.Name})";
    }
  }

  internal void CreateNewWorksheet()
  {
    if (this.m_WB == null)
    {
      // ISSUE: reference to a compiler-generated method
      this.m_WB = this.m_XL.Workbooks.Add((object) Missing.Value);
      if (this.m_WB.Sheets.Count == 3)
      {
        // ISSUE: reference to a compiler-generated field
        if (CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__0 == null)
        {
          // ISSUE: reference to a compiler-generated field
          CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__0 = CallSite<Action<CallSite, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Delete", (IEnumerable<Type>) null, typeof (CApCTRExcelExporter), (IEnumerable<CSharpArgumentInfo>) new CSharpArgumentInfo[1]
          {
            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, (string) null)
          }));
        }
        // ISSUE: reference to a compiler-generated field
        // ISSUE: reference to a compiler-generated field
        CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__0.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__0, this.m_WB.Sheets[(object) 2]);
        // ISSUE: reference to a compiler-generated field
        if (CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__1 == null)
        {
          // ISSUE: reference to a compiler-generated field
          CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__1 = CallSite<Action<CallSite, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Delete", (IEnumerable<Type>) null, typeof (CApCTRExcelExporter), (IEnumerable<CSharpArgumentInfo>) new CSharpArgumentInfo[1]
          {
            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, (string) null)
          }));
        }
        // ISSUE: reference to a compiler-generated field
        // ISSUE: reference to a compiler-generated field
        CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__1.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__1, this.m_WB.Sheets[(object) 1]);
      }
      // ISSUE: reference to a compiler-generated field
      if (CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__2 == null)
      {
        // ISSUE: reference to a compiler-generated field
        CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__2 = CallSite<Func<CallSite, object, _Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof (_Worksheet), typeof (CApCTRExcelExporter)));
      }
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      this.m_Worksheet = CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__2.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__2, this.m_WB.ActiveSheet);
    }
    else
    {
      // ISSUE: reference to a compiler-generated field
      if (CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__3 == null)
      {
        // ISSUE: reference to a compiler-generated field
        CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__3 = CallSite<Func<CallSite, object, _Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof (_Worksheet), typeof (CApCTRExcelExporter)));
      }
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated method
      this.m_Worksheet = CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__3.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__20.\u003C\u003Ep__3, this.m_WB.Worksheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing));
    }
  }

  internal void CreateExcelSheetForTimerSettings()
  {
    this.CreateNewWorksheet();
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__0 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__0 = CallSite<Action<CallSite, _Worksheet, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Move", (IEnumerable<Type>) null, typeof (CApCTRExcelExporter), (IEnumerable<CSharpArgumentInfo>) new CSharpArgumentInfo[3]
      {
        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, (string) null),
        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, (string) null),
        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, (string) null)
      }));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__0.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__0, this.m_Worksheet, Type.Missing, this.m_WB.Worksheets[(object) this.m_WB.Worksheets.Count]);
    this.m_Worksheet.Name = this.m_rm.GetString("REPORT_SETTINGS");
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__1 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__1 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof (Range), typeof (CApCTRExcelExporter)));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    // ISSUE: variable of a compiler-generated type
    Range oRng = CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__1.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__1, this.m_Worksheet.Cells[(object) 1, (object) 1]);
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 0, (object) 0).Value2 = (object) this.m_rm.GetString("USER_TIMERS");
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 0, (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 0, (object) 0).Interior.ColorIndex = (object) 24;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 0, (object) 0).ColumnWidth = (object) 20;
    if (TxOlpRoboticSimulationEventsManager.Instance.IgnoreUserTimers)
    {
      // ISSUE: reference to a compiler-generated method
      oRng.get_Offset((object) 0, (object) 1).Value2 = (object) this.m_rm.GetString("IGNORED_STRING");
    }
    else
    {
      // ISSUE: reference to a compiler-generated method
      oRng.get_Offset((object) 0, (object) 1).Value2 = (object) this.m_rm.GetString("ACTIVE_STRING");
    }
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 0, (object) 1).ColumnWidth = (object) 10;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 1, (object) 0).Value2 = (object) this.m_rm.GetString("TIMER_PRIORITIES");
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 1, (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 1, (object) 0).Interior.ColorIndex = (object) 24;
    if (TxOlpRoboticSimulationEventsManager.Instance.IgnoreTimerPriority)
    {
      // ISSUE: reference to a compiler-generated method
      oRng.get_Offset((object) 1, (object) 1).Value2 = (object) this.m_rm.GetString("IGNORED_STRING");
    }
    else
    {
      // ISSUE: reference to a compiler-generated method
      oRng.get_Offset((object) 1, (object) 1).Value2 = (object) this.m_rm.GetString("ACTIVE_STRING");
    }
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_INTERNAL_TIMER_NAME");
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 0).Interior.ColorIndex = (object) 24;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 1).Value2 = (object) this.m_rm.GetString("HEADER_INTERNAL_TIMER_PRIORITY");
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 1).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 1).Interior.ColorIndex = (object) 24;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 2).Value2 = (object) this.m_rm.GetString("HEADER_INTERNAL_TIMER_STATUS");
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 2).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) 3, (object) 2).Interior.ColorIndex = (object) 24;
    string timerName1 = ((TxOlpCTRInternalEvent) 0).ToString();
    int line1 = 4;
    this.FillOneLineOfSettings(oRng, line1, timerName1);
    TxOlpCTRInternalEvent ctrInternalEvent = (TxOlpCTRInternalEvent) 1;
    string timerName2 = ctrInternalEvent.ToString();
    int line2 = line1 + 1;
    this.FillOneLineOfSettings(oRng, line2, timerName2);
    ctrInternalEvent = (TxOlpCTRInternalEvent) 4;
    string timerName3 = ctrInternalEvent.ToString();
    int line3 = line2 + 1;
    this.FillOneLineOfSettings(oRng, line3, timerName3);
    ctrInternalEvent = (TxOlpCTRInternalEvent) 3;
    string timerName4 = ctrInternalEvent.ToString();
    int line4 = line3 + 1;
    this.FillOneLineOfSettings(oRng, line4, timerName4);
    ctrInternalEvent = (TxOlpCTRInternalEvent) 2;
    string timerName5 = ctrInternalEvent.ToString();
    int line5 = line4 + 1;
    this.FillOneLineOfSettings(oRng, line5, timerName5);
    ctrInternalEvent = (TxOlpCTRInternalEvent) 5;
    string timerName6 = ctrInternalEvent.ToString();
    int line6 = line5 + 1;
    this.FillOneLineOfSettings(oRng, line6, timerName6);
    // ISSUE: reference to a compiler-generated method
    // ISSUE: variable of a compiler-generated type
    Range range1 = this.m_Worksheet.get_Range((object) "A1", (object) "B2");
    range1.Borders.LineStyle = (object) XlLineStyle.xlContinuous;
    // ISSUE: reference to a compiler-generated method
    // ISSUE: variable of a compiler-generated type
    Range range2 = this.m_Worksheet.get_Range((object) "A4", (object) "C10");
    range2.Borders.LineStyle = (object) XlLineStyle.xlContinuous;
    this.m_Worksheet.UsedRange.VerticalAlignment = (object) XlVAlign.xlVAlignTop;
    this.m_Worksheet.UsedRange.HorizontalAlignment = (object) XlHAlign.xlHAlignLeft;
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__2 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__2 = CallSite<Func<CallSite, object, _Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof (_Worksheet), typeof (CApCTRExcelExporter)));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    // ISSUE: variable of a compiler-generated type
    _Worksheet worksheet = CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__2.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__21.\u003C\u003Ep__2, this.m_WB.Worksheets[(object) 1]);
    // ISSUE: reference to a compiler-generated method
    worksheet.Activate();
  }

  public void ExportWorkweetToFile(string sheetName, string filePath)
  {
    if (this.m_WB == null)
      return;
    if (File.Exists(filePath))
      File.Delete(filePath);
    foreach (Worksheet sheet in this.m_WB.Sheets)
    {
      if (sheet.Name == sheetName)
      {
        // ISSUE: reference to a compiler-generated method
        sheet.SaveAs(filePath, (object) XlFileFormat.xlCSV, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
        break;
      }
    }
  }

  public void CloseWorkBook(bool saveChanges)
  {
    if (this.m_WB == null)
      return;
    // ISSUE: reference to a compiler-generated method
    this.m_WB.Close((object) saveChanges, Type.Missing, Type.Missing);
  }

  internal void FillOneLineOfSettings(Range oRng, int line, string timerName)
  {
    // ISSUE: reference to a compiler-generated method
    oRng.get_Offset((object) line, (object) 0).Value2 = (object) timerName;
    if (TxOlpRoboticSimulationEventsManager.Instance.IsTimerActive(timerName))
    {
      // ISSUE: reference to a compiler-generated method
      oRng.get_Offset((object) line, (object) 1).Value2 = (object) this.GetInternalTimerPriority(timerName);
      // ISSUE: reference to a compiler-generated method
      oRng.get_Offset((object) line, (object) 2).Value2 = (object) this.m_rm.GetString("ACTIVE_STRING");
    }
    else
    {
      // ISSUE: reference to a compiler-generated method
      oRng.get_Offset((object) line, (object) 1).Value2 = (object) this.m_rm.GetString("NA_STRING");
      // ISSUE: reference to a compiler-generated method
      oRng.get_Offset((object) line, (object) 2).Value2 = (object) this.m_rm.GetString("INACTIVE_STRING");
    }
  }

  internal void GetTimerNamesAndTotals(
    List<CApCTRTimer> timers,
    Dictionary<string, double> timerTotals,
    ref double totalOfAllTimers)
  {
    totalOfAllTimers = 0.0;
    foreach (CApCTRTimer timer in timers)
    {
      if (TxRobot.op_Equality(this.masterRobot, (ITxObject) null) || TxRobot.op_Equality(timer.Robot, (ITxObject) this.masterRobot))
      {
        if (timerTotals.ContainsKey(timer.Name))
          timerTotals[timer.Name] += timer.ActiveDuration;
        else
          timerTotals.Add(timer.Name, timer.ActiveDuration);
        totalOfAllTimers += timer.ActiveDuration;
      }
    }
  }

  internal string GetInternalTimerPriority(string internalTimerName)
  {
    string internalTimerPriority;
    if (TxOlpRoboticSimulationEventsManager.Instance.IgnoreTimerPriority || !TxOlpRoboticSimulationEventsManager.Instance.SupportPriority(internalTimerName))
    {
      internalTimerPriority = this.m_rm.GetString("NA_STRING");
    }
    else
    {
      int? nullable = TxOlpRoboticSimulationEventsManager.Instance.TimerPriority(internalTimerName);
      internalTimerPriority = !nullable.HasValue ? 5.ToString() : nullable.Value.ToString();
    }
    return internalTimerPriority;
  }

  internal void ShowExcel()
  {
    this.m_XL.Visible = true;
    Thread.CurrentThread.CurrentCulture = this.m_oldCI;
  }

  private void FillExcelReportHeader(
    List<CApCTRTimer> timers,
    int cycleNumber,
    string programNumber,
    bool isCompoundEquipment)
  {
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__28.\u003C\u003Ep__0 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__28.\u003C\u003Ep__0 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof (Range), typeof (CApCTRExcelExporter)));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    // ISSUE: variable of a compiler-generated type
    Range range = CApCTRExcelExporter.\u003C\u003Eo__28.\u003C\u003Ep__0.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__28.\u003C\u003Ep__0, this.m_Worksheet.Cells[(object) 1, (object) 1]);
    int RowOffset1 = 0;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset1, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_DATE");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset1, (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset1, (object) 0).ColumnWidth = (object) 20;
    string str = Convert.ToString(DateTime.Now);
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset1, (object) 1).Value2 = (object) str;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset1, (object) 1).ColumnWidth = (object) 20;
    int RowOffset2 = RowOffset1 + 1;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset2, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_STUDY_NAME");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset2, (object) 0).Font.Bold = (object) true;
    if (TxTcUtilities.IsTcAnyPlatform)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset2, (object) 1).Value2 = (object) TxApplication.ActiveDocument.PhysicalRoot.Name;
    }
    else
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset2, (object) 1).Value2 = (object) ((ITxObject) TxApplication.ActiveDocument.CurrentStudy).Name;
    }
    int RowOffset3 = RowOffset2 + 1;
    if (isCompoundEquipment)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset3, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_COMPOUND_NAME");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset3, (object) 1).Value2 = (object) $"{((ITxObject) ((TxBaseGeometryCreationObject) timers[0].Robot).Collection).Name}  (Master robot: {((TxBaseGeometryCreationObject) this.masterRobot).Name})";
      int modelNumber = 0;
      this.GetModelNumberOfCompoundEquipmentMasterRobot(this.masterRobot, timers, ref modelNumber);
      programNumber = modelNumber.ToString();
    }
    else
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset3, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_ROBOT_NAME");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset3, (object) 1).Value2 = (object) ((TxBaseGeometryCreationObject) timers[0].Robot).Name;
    }
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset3, (object) 0).Font.Bold = (object) true;
    int RowOffset4 = RowOffset3 + 1;
    bool flag = this.isCycleCompleted(timers);
    if (isCompoundEquipment)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset4, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_MODEL_NUMBER");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset4, (object) 0).Font.Bold = (object) true;
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset4, (object) 1).Value2 = (object) programNumber;
      ++RowOffset4;
    }
    else if (!flag || cycleNumber != 0)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset4, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_PROGRAM_NUMBER");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset4, (object) 0).Font.Bold = (object) true;
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset4, (object) 1).Value2 = (object) programNumber;
      ++RowOffset4;
    }
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset4, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_RCS_STATUS");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset4, (object) 0).Font.Bold = (object) true;
    if (this.IsRCSSimulationInUse(timers[0].Robot))
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset4, (object) 1).Value2 = (object) this.m_rm.GetString("ON_STRING");
    }
    else
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset4, (object) 1).Value2 = (object) this.m_rm.GetString("OFF_STRING");
    }
    int RowOffset5 = RowOffset4 + 1;
    if (!flag || cycleNumber != 0)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset5, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_CYCLE_NUMBER");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset5, (object) 0).Font.Bold = (object) true;
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset5, (object) 1).Value2 = (object) cycleNumber;
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset5, (object) 1).NumberFormat = (object) "0";
      ++RowOffset5;
    }
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset5, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_CYCLE_START_TIME");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset5, (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset5, (object) 1).Value2 = (object) this.m_cycleStartTime;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset5, (object) 1).NumberFormat = (object) this.CreateFormatStringForTime();
    int RowOffset6 = RowOffset5 + 1;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset6, (object) 0).Value2 = (object) this.m_rm.GetString("TIME_UNITS");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset6, (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset6, (object) 1).Value2 = (object) TxApplication.Options.Units.TimeUnitName;
    int RowOffset7 = RowOffset6 + 1;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset7, (object) 0).Value2 = (object) this.m_rm.GetString("HEADER_COMMENTS");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) RowOffset7, (object) 0).Font.Bold = (object) true;
    if (!flag)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) RowOffset7, (object) 1).Value2 = (object) this.m_rm.GetString("CYCLE_IS_STOPPED_IN_THE_MIDDLE_FORMAT");
    }
    this.m_rowsInHeader = RowOffset7;
  }

  private bool isCycleCompleted(List<CApCTRTimer> timers)
  {
    bool flag = true;
    foreach (CApCTRTimer timer in timers)
    {
      if (!(timer.Name != "StartCycle") && timer.TimerIsStoppedInTheMiddle)
      {
        flag = false;
        break;
      }
    }
    return flag;
  }

  private void FillExcelTotals(List<CApCTRTimer> timers)
  {
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__30.\u003C\u003Ep__0 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__30.\u003C\u003Ep__0 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof (Range), typeof (CApCTRExcelExporter)));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    // ISSUE: variable of a compiler-generated type
    Range range = CApCTRExcelExporter.\u003C\u003Eo__30.\u003C\u003Ep__0.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__30.\u003C\u003Ep__0, this.m_Worksheet.Cells[(object) (this.m_rowsInHeader + 3), (object) 1]);
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) 0).Value2 = (object) this.m_rm.GetString("TOTALS_TITLE");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) 0).Interior.ColorIndex = (object) 24;
    Dictionary<string, double> timerTotals = new Dictionary<string, double>();
    double totalOfAllTimers = 0.0;
    this.GetTimerNamesAndTotals(timers, timerTotals, ref totalOfAllTimers);
    int num1 = 0;
    foreach (string key in timerTotals.Keys)
    {
      if (!(key == "StartCycle") && !(key == "EndCycle") && !(key == "EndOfSimulation") && !(key == ((TxOlpCTRInternalEvent) 5).ToString()))
      {
        // ISSUE: reference to a compiler-generated method
        range.get_Offset((object) (num1 + 1), (object) 0).Value2 = (object) key;
        // ISSUE: reference to a compiler-generated method
        range.get_Offset((object) (num1 + 1), (object) 1).Value2 = (object) timerTotals[key];
        // ISSUE: reference to a compiler-generated method
        range.get_Offset((object) (num1 + 1), (object) 1).NumberFormat = (object) this.CreateFormatStringForTime();
        ++num1;
      }
    }
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num1 + 1), (object) 0).Value2 = (object) this.m_rm.GetString("TOTALS_TIMERS");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num1 + 1), (object) 0).Interior.ColorIndex = (object) 36;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num1 + 1), (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num1 + 1), (object) 1).Value2 = (object) totalOfAllTimers;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num1 + 1), (object) 1).NumberFormat = (object) this.CreateFormatStringForTime();
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num1 + 1), (object) 1).Interior.ColorIndex = (object) 36;
    int num2 = num1 + 1;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num2 + 1), (object) 0).Value2 = (object) this.m_rm.GetString("TOTALS_WELD_COUNT");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num2 + 1), (object) 1).Value2 = (object) this.m_weldCount;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) (num2 + 1), (object) 1).NumberFormat = (object) "0";
    this.m_totalCount = num2 + 1;
    this.m_timerTableTitleRow = this.m_rowsInHeader + 3 + this.m_totalCount + 3;
    this.m_summaryRow = this.m_timerTableTitleRow + timers.Count + 2;
  }

  private void FillExcelTimerTableTitle(bool isCompoundEquipment)
  {
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__31.\u003C\u003Ep__0 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__31.\u003C\u003Ep__0 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof (Range), typeof (CApCTRExcelExporter)));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    // ISSUE: variable of a compiler-generated type
    Range range = CApCTRExcelExporter.\u003C\u003Eo__31.\u003C\u003Ep__0.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__31.\u003C\u003Ep__0, this.m_Worksheet.Cells[(object) this.m_timerTableTitleRow, (object) 1]);
    // ISSUE: reference to a compiler-generated method
    this.m_Worksheet.get_Range((object) this.IndexToString(0, this.m_timerTableTitleRow), (object) this.IndexToString(this.m_lastColumn, this.m_timerTableTitleRow)).EntireRow.Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    this.m_Worksheet.get_Range((object) this.IndexToString(0, this.m_timerTableTitleRow), (object) this.IndexToString(this.m_lastColumn, this.m_timerTableTitleRow)).Interior.ColorIndex = (object) 24;
    if (!this.m_showTimerPriorityColumns)
    {
      this.m_indexTimerName -= 2;
      this.m_indexParameters -= 2;
      this.m_indexTimerDescription -= 2;
      this.m_indexOLPCommands -= 2;
      this.m_indexFanucRJComments -= 2;
      this.m_indexRobotName -= 2;
    }
    if (!this.m_showControllerComment)
      --this.m_indexRobotName;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexStartTime).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_START_TIME");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexStartTime).ColumnWidth = (object) 20;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexActiveDuration).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_ACTIVE_DURATION");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexActiveDuration).ColumnWidth = (object) 20;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexEndTime).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_END_TIME");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexEndTime).ColumnWidth = (object) 20;
    if (this.m_showTimerPriorityColumns)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) 0, (object) this.m_indexInactiveDuration).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_INACTIVE_DURATION");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) 0, (object) this.m_indexInactiveDuration).ColumnWidth = (object) 22;
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) 0, (object) this.m_indexPriority).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_TIMER_PRIORITY");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) 0, (object) this.m_indexPriority).ColumnWidth = (object) 20;
    }
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexTimerName).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_TIMER_NAME");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexTimerName).ColumnWidth = (object) 40;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexParameters).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_PARAMETERS");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexParameters).ColumnWidth = (object) 40;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexTimerDescription).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_TIMER_DESCRIPTION");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexTimerDescription).ColumnWidth = (object) 40;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexOLPCommands).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_OLP_COMMANDS");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) this.m_indexOLPCommands).ColumnWidth = (object) 40;
    if (this.m_showControllerComment)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) 0, (object) this.m_indexFanucRJComments).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_FANUC_RJ_COMMENTS");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) 0, (object) this.m_indexFanucRJComments).ColumnWidth = (object) 40;
    }
    if (isCompoundEquipment)
    {
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) 0, (object) this.m_indexRobotName).Value2 = (object) this.m_rm.GetString("TABLE_TITLE_ROBOT_NAME");
      // ISSUE: reference to a compiler-generated method
      range.get_Offset((object) 0, (object) this.m_indexRobotName).ColumnWidth = (object) 40;
    }
    this.AddListObject();
  }

  private void FillExcelTimerTable(List<CApCTRTimer> timers, bool isCompoundEquipment)
  {
    if (timers.Count <= 0)
      return;
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__32.\u003C\u003Ep__0 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__32.\u003C\u003Ep__0 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof (Range), typeof (CApCTRExcelExporter)));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    // ISSUE: variable of a compiler-generated type
    Range range1 = CApCTRExcelExporter.\u003C\u003Eo__32.\u003C\u003Ep__0.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__32.\u003C\u003Ep__0, this.m_Worksheet.Cells[(object) (this.m_timerTableTitleRow + 1), (object) 1]);
    int RowOffset = 0;
    foreach (CApCTRTimer timer in timers)
    {
      if (!(timer.Name == "StartCycle") && !(timer.Name == "EndCycle") && !(timer.Name == "EndOfSimulation"))
      {
        double num1 = timer.StartTime - this.m_cycleStartTime;
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexStartTime).Value2 = (object) num1;
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexStartTime).NumberFormat = (object) this.CreateFormatStringForTime();
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexActiveDuration).Value2 = (object) timer.ActiveDuration;
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexActiveDuration).NumberFormat = (object) this.CreateFormatStringForTime();
        double num2 = timer.ComputeEndTime() - this.m_cycleStartTime;
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexEndTime).Value2 = (object) num2;
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexEndTime).NumberFormat = (object) this.CreateFormatStringForTime();
        if (this.m_showTimerPriorityColumns)
        {
          // ISSUE: reference to a compiler-generated method
          range1.get_Offset((object) RowOffset, (object) this.m_indexInactiveDuration).Value2 = (object) timer.InactiveDurationToString();
          // ISSUE: reference to a compiler-generated method
          range1.get_Offset((object) RowOffset, (object) this.m_indexInactiveDuration).NumberFormat = (object) this.CreateFormatStringForTime();
          // ISSUE: reference to a compiler-generated method
          range1.get_Offset((object) RowOffset, (object) this.m_indexPriority).Value2 = (object) timer.PriorityToString();
        }
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexTimerName).NumberFormat = (object) "@";
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexTimerName).Value2 = (object) timer.Name;
        if (timer.Object1 != null)
        {
          if (timer.Object1 is ITxObject)
          {
            if ((timer.Object1 as ITxObject).IsValid())
            {
              if (timer.Name == "MotionToLocation")
              {
                List<string> simulationRepresentations = this.GetAllOLPCommandsSimulationRepresentations(timer.Robot, timer.Object1 as ITxRoboticOperation);
                if (simulationRepresentations != null && simulationRepresentations.Count > 0)
                {
                  // ISSUE: reference to a compiler-generated method
                  range1.get_Offset((object) RowOffset, (object) this.m_indexOLPCommands).NumberFormat = (object) "@";
                  // ISSUE: reference to a compiler-generated method
                  range1.get_Offset((object) RowOffset, (object) this.m_indexOLPCommands).Value2 = (object) simulationRepresentations[0];
                  for (int index = 1; index < simulationRepresentations.Count; ++index)
                  {
                    // ISSUE: reference to a compiler-generated method
                    // ISSUE: variable of a compiler-generated type
                    Range range2 = range1.get_Offset((object) RowOffset, (object) this.m_indexOLPCommands);
                    // ISSUE: variable of a compiler-generated type
                    Range range3 = range2;
                    // ISSUE: reference to a compiler-generated field
                    if (CApCTRExcelExporter.\u003C\u003Eo__32.\u003C\u003Ep__1 == null)
                    {
                      // ISSUE: reference to a compiler-generated field
                      CApCTRExcelExporter.\u003C\u003Eo__32.\u003C\u003Ep__1 = CallSite<Func<CallSite, object, string, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.AddAssign, typeof (CApCTRExcelExporter), (IEnumerable<CSharpArgumentInfo>) new CSharpArgumentInfo[2]
                      {
                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, (string) null),
                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, (string) null)
                      }));
                    }
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: reference to a compiler-generated field
                    object obj = CApCTRExcelExporter.\u003C\u003Eo__32.\u003C\u003Ep__1.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__32.\u003C\u003Ep__1, range2.Value2, "\n" + simulationRepresentations[index]);
                    range3.Value2 = obj;
                  }
                }
                if (timer.Object1 is TxWeldLocationOperation)
                  ++this.m_weldCount;
                if (this.m_showControllerComment)
                {
                  // ISSUE: reference to a compiler-generated method
                  range1.get_Offset((object) RowOffset, (object) this.m_indexFanucRJComments).NumberFormat = (object) "@";
                  // ISSUE: reference to a compiler-generated method
                  range1.get_Offset((object) RowOffset, (object) this.m_indexFanucRJComments).Value2 = (object) this.GetCommentFromLocation(timer.Robot, timer.Object1 as ITxRoboticOperation);
                }
              }
              // ISSUE: reference to a compiler-generated method
              range1.get_Offset((object) RowOffset, (object) this.m_indexParameters).NumberFormat = (object) "@";
              // ISSUE: reference to a compiler-generated method
              range1.get_Offset((object) RowOffset, (object) this.m_indexParameters).Value2 = (object) (timer.Object1 as ITxObject).Name;
            }
          }
          else
          {
            // ISSUE: reference to a compiler-generated method
            range1.get_Offset((object) RowOffset, (object) this.m_indexParameters).NumberFormat = (object) "@";
            string str = !(timer.Name == ((TxOlpCTRInternalEvent) 5).ToString()) ? timer.Object1.ToString() : $"{timer.Object1?.ToString()} = {timer.Object2?.ToString()}";
            // ISSUE: reference to a compiler-generated method
            range1.get_Offset((object) RowOffset, (object) this.m_indexParameters).Value2 = (object) str;
          }
        }
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexTimerDescription).NumberFormat = (object) "@";
        // ISSUE: reference to a compiler-generated method
        range1.get_Offset((object) RowOffset, (object) this.m_indexTimerDescription).Value2 = (object) this.GetTimerDescription(timer);
        if (isCompoundEquipment)
        {
          // ISSUE: reference to a compiler-generated method
          range1.get_Offset((object) RowOffset, (object) this.m_indexRobotName).NumberFormat = (object) "@";
          // ISSUE: reference to a compiler-generated method
          range1.get_Offset((object) RowOffset, (object) this.m_indexRobotName).Value2 = (object) ((TxBaseGeometryCreationObject) timer.Robot).Name;
        }
        ++RowOffset;
      }
    }
  }

  private void FillExcelEndSummary(List<CApCTRTimer> timers)
  {
    if (timers.Count <= 0)
      return;
    double num = timers[timers.Count - 1].ComputeEndTime() - this.m_cycleStartTime;
    // ISSUE: reference to a compiler-generated field
    if (CApCTRExcelExporter.\u003C\u003Eo__33.\u003C\u003Ep__0 == null)
    {
      // ISSUE: reference to a compiler-generated field
      CApCTRExcelExporter.\u003C\u003Eo__33.\u003C\u003Ep__0 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof (Range), typeof (CApCTRExcelExporter)));
    }
    // ISSUE: reference to a compiler-generated field
    // ISSUE: reference to a compiler-generated field
    // ISSUE: variable of a compiler-generated type
    Range range = CApCTRExcelExporter.\u003C\u003Eo__33.\u003C\u003Ep__0.Target((CallSite) CApCTRExcelExporter.\u003C\u003Eo__33.\u003C\u003Ep__0, this.m_Worksheet.Cells[(object) this.m_summaryRow, (object) 1]);
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) 0).Value2 = (object) this.m_rm.GetString("SUMMARY_CYCLE_TIME");
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) 0).Font.Bold = (object) true;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) 1).Value2 = (object) num;
    // ISSUE: reference to a compiler-generated method
    range.get_Offset((object) 0, (object) 1).NumberFormat = (object) this.CreateFormatStringForTime();
  }

  private void FormatWorksheet(int nTimers)
  {
    this.m_Worksheet.UsedRange.VerticalAlignment = (object) XlVAlign.xlVAlignTop;
    this.m_Worksheet.UsedRange.HorizontalAlignment = (object) XlHAlign.xlHAlignLeft;
    // ISSUE: reference to a compiler-generated method
    this.m_Worksheet.get_Range((object) this.IndexToString(0, 1), (object) this.IndexToString(this.m_lastColumn, 1)).EntireColumn.Font.Size = (object) 13;
    // ISSUE: reference to a compiler-generated method
    // ISSUE: variable of a compiler-generated type
    Range range1 = this.m_Worksheet.get_Range((object) this.IndexToString(0, 1), (object) this.IndexToString(1, this.m_rowsInHeader + 1));
    range1.Borders.LineStyle = (object) XlLineStyle.xlContinuous;
    // ISSUE: reference to a compiler-generated method
    // ISSUE: variable of a compiler-generated type
    Range range2 = this.m_Worksheet.get_Range((object) this.IndexToString(0, this.m_rowsInHeader + 3 + 1), (object) this.IndexToString(1, this.m_timerTableTitleRow - 3));
    range2.Borders.LineStyle = (object) XlLineStyle.xlContinuous;
    // ISSUE: reference to a compiler-generated method
    this.m_Worksheet.get_Range((object) this.IndexToString(1, this.m_rowsInHeader + 3 + 1), (object) this.IndexToString(1, this.m_rowsInHeader + 3 + this.m_totalCount)).HorizontalAlignment = (object) XlHAlign.xlHAlignCenterAcrossSelection;
    // ISSUE: reference to a compiler-generated method
    // ISSUE: variable of a compiler-generated type
    Range range3 = this.m_Worksheet.get_Range((object) this.IndexToString(0, this.m_timerTableTitleRow), (object) this.IndexToString(this.m_lastColumn, this.m_timerTableTitleRow + nTimers));
    range3.WrapText = (object) true;
    range3.Borders.LineStyle = (object) XlLineStyle.xlContinuous;
    if (TxOlpRoboticSimulationEventsManager.Instance.IgnoreTimerPriority)
    {
      // ISSUE: reference to a compiler-generated method
      range3.get_Range((object) "A1", (object) this.IndexToString(this.m_indexEndTime, this.m_timerTableTitleRow + nTimers)).HorizontalAlignment = (object) XlHAlign.xlHAlignCenterAcrossSelection;
    }
    else
    {
      // ISSUE: reference to a compiler-generated method
      range3.get_Range((object) "A1", (object) this.IndexToString(this.m_indexPriority, this.m_timerTableTitleRow + nTimers)).HorizontalAlignment = (object) XlHAlign.xlHAlignCenterAcrossSelection;
    }
    // ISSUE: reference to a compiler-generated method
    this.m_Worksheet.get_Range((object) this.IndexToString(0, this.m_timerTableTitleRow), (object) this.IndexToString(0, this.m_timerTableTitleRow)).HorizontalAlignment = (object) XlHAlign.xlHAlignCenterAcrossSelection;
    // ISSUE: reference to a compiler-generated method
    // ISSUE: variable of a compiler-generated type
    Range range4 = this.m_Worksheet.get_Range((object) this.IndexToString(0, this.m_summaryRow), (object) this.IndexToString(1, this.m_summaryRow));
    range4.Borders.LineStyle = (object) XlLineStyle.xlContinuous;
    range4.Interior.ColorIndex = (object) 36;
    range4.HorizontalAlignment = (object) XlHAlign.xlHAlignLeft;
  }

  private string CreateFormatStringForTime()
  {
    string formatStringForTime = "0.0";
    for (int index = 1; index < TxApplication.Options.Units.TimeDigitsAfterDecimalPoint; ++index)
      formatStringForTime += "0";
    return formatStringForTime;
  }

  private bool IsRCSSimulationInUse(TxRobot robot)
  {
    bool flag = false;
    if (!robot.IsRCSTurnedOffForSimulationActions && TxRRSServicesProvider.DoesRcsExist(robot))
      flag = true;
    return flag;
  }

  private bool ShouldShowComment(TxRobot robot)
  {
    bool flag = false;
    if (robot.Controller.Name.Contains("Fanuc-Rj"))
      flag = true;
    return flag;
  }

  private string GetCommentFromLocation(TxRobot robot, ITxRoboticOperation location)
  {
    string commentFromLocation = "";
    ITxOlpRobotControllerParametersHandler parametersHandlerInstance = this.m_controllerUtilities.InitAndGetRobotControllerParametersHandlerInstance((ITxOperation) location);
    if (parametersHandlerInstance != null)
      commentFromLocation = parametersHandlerInstance.GetComplexRepresentation("Comment", (ITxOperation) location, (TxOlpCommandLayerRepresentation) 0);
    return commentFromLocation;
  }

  private List<string> GetAllOLPCommandsSimulationRepresentations(
    TxRobot robot,
    ITxRoboticOperation operation)
  {
    List<string> simulationRepresentations = new List<string>();
    TxOlpCommandServices olpCommandServices = (TxOlpCommandServices) null;
    try
    {
      olpCommandServices = new TxOlpCommandServices(robot);
    }
    catch
    {
    }
    if (operation != null && olpCommandServices != null)
    {
      foreach (object command in (Collection<ITxObject>) operation.Commands)
      {
        if (command is TxRoboticCompositeCommand)
        {
          TxRoboticCompositeCommand compositeCommand = command as TxRoboticCompositeCommand;
          try
          {
            string[] commandRepresentation = olpCommandServices.GetCommandRepresentation((TxOlpCommandLayerRepresentation) 0, compositeCommand, (ITxOperation) operation);
            if (commandRepresentation != null && commandRepresentation.Length != 0 && commandRepresentation[0].Length > 0)
              simulationRepresentations.AddRange((IEnumerable<string>) commandRepresentation);
            else
              simulationRepresentations.Add(((TxRoboticCommand) compositeCommand).Text);
          }
          catch (Exception ex)
          {
            simulationRepresentations.Add(((TxRoboticCommand) compositeCommand).Text);
          }
        }
        else if (command is TxRoboticCommand)
          simulationRepresentations.Add((command as TxRoboticCommand).Text);
      }
    }
    return simulationRepresentations;
  }

  private bool NoSheetWithThisName(string name)
  {
    foreach (_Worksheet sheet in this.m_XL.Sheets)
    {
      if (sheet.Name == name)
        return false;
    }
    return true;
  }

  private void ConvertNameToValidExcelTabName(string name_before, out string name_after)
  {
    string str = name_before.Replace('\\', '_').Replace('/', '_').Replace('?', '_').Replace('*', '_').Replace('[', '_').Replace(']', '_').Replace(':', '_').Replace('\'', '_');
    if (str.Length > 31 /*0x1F*/)
      name_after = str.Substring(0, 31 /*0x1F*/);
    else
      name_after = str;
  }

  private void AddListObject()
  {
    // ISSUE: reference to a compiler-generated method
    // ISSUE: variable of a compiler-generated type
    Range Source = this.m_Worksheet.get_Range((object) this.IndexToString(0, this.m_timerTableTitleRow), (object) this.IndexToString(this.m_lastColumn, this.m_timerTableTitleRow));
    Source.Font.Bold = (object) true;
    Source.Font.Color = (object) ColorTranslator.ToOle(Color.Black);
    // ISSUE: reference to a compiler-generated method
    // ISSUE: variable of a compiler-generated type
    ListObject listObject = this.m_Worksheet.ListObjects.Add(Source: (object) Source, LinkSource: (object) false, XlListObjectHasHeaders: XlYesNoGuess.xlYes, Destination: Type.Missing);
    listObject.ShowTableStyleColumnStripes = false;
    listObject.ShowTableStyleRowStripes = false;
    listObject.TableStyle = (object) "TableStyleMedium2";
  }

  private string IndexToString(int col, int row)
  {
    string str1 = "";
    int num = 65;
    char ch;
    if (col > 26)
    {
      string str2 = str1;
      ch = (char) (num + col / 26);
      string str3 = ch.ToString();
      str1 = str2 + str3;
    }
    string str4 = str1;
    ch = (char) (num + col % 26);
    string str5 = ch.ToString();
    return str4 + str5 + row.ToString();
  }

  private string GetTimerDescriptionForMotionToLocation(CApCTRTimer timer)
  {
    string motionToLocation = "";
    if (timer.Object1 != null)
    {
      if (timer.Object1 is ITxObject)
      {
        if ((timer.Object1 as ITxObject).IsValid())
        {
          if (timer.Object1 is TxRoboticViaLocationOperation)
            motionToLocation = this.m_rm.GetString("LOCATION_TYPE_VIA");
          else if (timer.Object1 is TxWeldLocationOperation)
            motionToLocation = this.m_rm.GetString("LOCATION_TYPE_WELD");
          else if (timer.Object1 is TxRoboticSeamLocationOperation)
            motionToLocation = this.m_rm.GetString("LOCATION_TYPE_SEAM");
        }
      }
      else
      {
        motionToLocation = "# Move";
        timer.Object2 = (object) null;
      }
    }
    return motionToLocation;
  }

  private string GetTimerDescriptionForWaitServoGun(CApCTRTimer timer)
  {
    string descriptionForWaitServoGun = "";
    if (timer.Object1 is TxServoGun && (timer.Object1 as ITxObject).IsValid() && timer.Object2 is double)
    {
      ITxDevice object1 = timer.Object1 as ITxDevice;
      TxObjectList externalAxes = timer.Robot.ExternalAxes;
      TxObjectList drivingJoints = object1.DrivingJoints;
      TxJoint txJoint1 = (TxJoint) null;
      foreach (TxJoint txJoint2 in (Collection<ITxObject>) drivingJoints)
      {
        if (((Collection<ITxObject>) externalAxes).Contains((ITxObject) txJoint2))
        {
          txJoint1 = txJoint2;
          break;
        }
      }
      if (TxJoint.op_Inequality(txJoint1, (ITxObject) null))
      {
        TxObjectList poseList = object1.PoseList;
        string str = (string) null;
        bool flag = true;
        foreach (TxPose txPose in (Collection<ITxObject>) poseList)
        {
          if (new TxDevicePoseData(object1, txPose.PoseData).GetJointValue(txJoint1).Equals(timer.Object2))
          {
            if (flag)
            {
              str += txPose.Name;
              flag = false;
            }
            else
              str = $"{str}/{txPose.Name}";
          }
        }
        if (str != null)
          descriptionForWaitServoGun = $" [{str}] ";
      }
    }
    return descriptionForWaitServoGun;
  }

  private string GetTimerDescription(CApCTRTimer timer)
  {
    string timerDescription = "";
    if (timer.Name == "MotionToLocation")
      timerDescription = this.GetTimerDescriptionForMotionToLocation(timer);
    if (!string.IsNullOrEmpty(timer.Description))
      timerDescription += timer.Description;
    else if (timer.Object2 != null)
    {
      if (timer.Object2 is ITxObject && (timer.Object2 as ITxObject).IsValid())
        timerDescription += (timer.Object2 as ITxObject).Name;
      else if (timer.Name == ((TxOlpCTRInternalEvent) 5).ToString())
      {
        if (timer.Object3 is ITxObject && (timer.Object3 as ITxObject).IsValid())
          timerDescription = $"{timerDescription}{this.m_rm.GetString("SIGNAL_DESTINATION")} {(timer.Object3 as ITxObject).Name}";
      }
      else
        timerDescription += timer.Object2?.ToString();
      if (timer.Name == ((TxOlpCTRInternalEvent) 1).ToString())
        timerDescription += this.GetTimerDescriptionForWaitServoGun(timer);
    }
    if (timer.TimerIsStoppedInTheMiddle)
      timerDescription += this.m_rm.GetString("STOPPED_INDICATOR");
    return timerDescription;
  }

  private bool IsRobotPartOfCompoundEquipmentWithMoreThanOneRobot(
    TxRobot robotId,
    ref string programNumber)
  {
    if (robotId != null && ((TxBaseGeometryCreationObject) robotId).Collection != null)
    {
      ITxObjectCollection collection = ((TxBaseGeometryCreationObject) robotId).Collection;
      if (collection is ITxComponent && (collection as ITxComponent).IsEquipment && ((Collection<ITxObject>) ((ITxObject) collection).Collection.GetAllDescendants((ITxTypeFilter) new TxTypeFilter(typeof (TxRobot)))).Count > 1)
      {
        string str = "Model number";
        programNumber = str;
        return true;
      }
    }
    return false;
  }

  private TxRobot GetMasterRobot(ITxObjectCollection collectionId)
  {
    TxObjectList allDescendants = ((ITxObject) collectionId).Collection.GetAllDescendants((ITxTypeFilter) new TxTypeFilter(typeof (TxRobot)));
    foreach (TxRobot masterRobot in (Collection<ITxObject>) allDescendants)
    {
      TxRoboticParam instanceParameter = masterRobot.GetInstanceParameter("F100_UNIT_NUMBER");
      if (instanceParameter != null && (instanceParameter as TxRoboticIntParam).Value == 1)
        return masterRobot;
    }
    return ((Collection<ITxObject>) allDescendants)[0] as TxRobot;
  }

  private bool GetModelNumberOfCompoundEquipmentMasterRobot(
    TxRobot masterRobot,
    List<CApCTRTimer> timers,
    ref int modelNumber)
  {
    foreach (CApCTRTimer timer in timers)
    {
      if (timer.Name == "MotionToLocation" && TxRobot.op_Equality(timer.Robot, (ITxObject) masterRobot) && timer.Object1 is ITxRoboticOperation && (timer.Object1 as ITxObject).IsValid())
      {
        TxWeldOperation collection1 = (timer.Object1 as ITxObject).Collection as TxWeldOperation;
        if (TxWeldOperation.op_Inequality(collection1, (ITxObject) null))
        {
          if (!(((ITxRoboticOperation) collection1).GetParameter("F100_MODEL_NUMBER") is TxRoboticIntParam parameter))
          {
            TxWeldOperation collection2 = ((ITxObject) collection1).Collection as TxWeldOperation;
            if (TxWeldOperation.op_Inequality(collection2, (ITxObject) null))
              parameter = ((ITxRoboticOperation) collection2).GetParameter("F100_MODEL_NUMBER") as TxRoboticIntParam;
          }
          if (parameter != null)
          {
            modelNumber = parameter.Value;
            return true;
          }
        }
      }
    }
    return false;
  }

  private void InitiliazeColumnsIndex()
  {
    this.m_indexStartTime = 0;
    this.m_indexActiveDuration = 1;
    this.m_indexEndTime = 2;
    this.m_indexInactiveDuration = 3;
    this.m_indexPriority = 4;
    this.m_indexTimerName = 5;
    this.m_indexParameters = 6;
    this.m_indexTimerDescription = 7;
    this.m_indexOLPCommands = 8;
    this.m_indexFanucRJComments = 9;
    this.m_indexRobotName = 10;
  }
}
